package com.study.other;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import cn.hutool.system.JavaInfo;
import cn.hutool.system.OsInfo;
import cn.hutool.system.SystemUtil;
import com.study.utils.DatePattern;
import org.joda.time.DateTime;

/**
 * @author study
 * @version 1.0
 * @date 2020/6/30 22:10
 */
public class Id {


    public static void main(String[] args) {
        JavaInfo javaInfo = SystemUtil.getJavaInfo();

        System.out.println(javaInfo);
        OsInfo osInfo = SystemUtil.getOsInfo();
        System.out.println(osInfo);
        ///////////////////////////////////////////
        //生成的UUID是带-的字符串，类似于：a5c8a5e8-df2b-4706-bea4-08d0939410e3
        String uuid = IdUtil.randomUUID();

        //生成的是不带-的字符串，类似于：b17f24ff026d40949c85a24f4f375d42
        String simpleUUID = IdUtil.simpleUUID();

        System.out.println(simpleUUID);
        System.out.println(uuid);

        //参数1为终端ID
        //参数2为数据中心ID
        Snowflake snowflake = IdUtil.createSnowflake(1, 1);
        long id = snowflake.nextId();


        for (int i = 0; i < 10; i++) {
            System.out.println(String.valueOf(snowflake.nextId()).length());
        }
        System.out.println(System.currentTimeMillis());
        System.out.println(String.valueOf(System.currentTimeMillis()).length());

        System.out.println(DatePattern.NORM_DATETIME_MS_PATTERN.length());


        System.out.println(new DateTime().toString(DatePattern.PURE_DATETIME_MS_PATTERN));
        System.out.println(new DateTime().toString(DatePattern.PURE_DATETIME_MS_PATTERN).length());
    }
}
